package com.luocc.ccdemo.widget

import android.content.Context
import android.graphics.Color
import android.graphics.Rect
import android.util.AttributeSet
import androidx.appcompat.widget.AppCompatEditText

/**
 * 后续得补充点内容
 */
class ClearEditText(context: Context, attrs: AttributeSet) : AppCompatEditText(context, attrs) {

    var mInputState: Int = INPUT_STATE_NORMAL
    override fun onFocusChanged(focused: Boolean, direction: Int, previouslyFocusedRect: Rect?) {
        super.onFocusChanged(focused, direction, previouslyFocusedRect)
        if (mInputState == INPUT_STATE_ERROR) {
            setTextColor(Color.RED)
        } else {
            setTextColor(Color.BLACK)
        }
    }

    companion object {
        const val INPUT_STATE_NORMAL = 0
        const val INPUT_STATE_FOCUS = 1
        const val INPUT_STATE_ERROR = 2
    }
}